package cumeo89.chii.client.ui;

import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.Widget;

import cumeo89.chii.client.util.MyChangeListener;
import cumeo89.chii.client.util.MyChangeListenerCollection;

public class MyDeckPanel extends DeckPanel {

	private MyChangeListenerCollection listeners = new MyChangeListenerCollection();
	
	public Widget getShownWidget() {
		return getWidget(getVisibleWidget());
	}
	
	public void setShownWidget(Widget widget) {
		showWidget(getWidgetIndex(widget));
	}
	
	@Override
	public void showWidget(int index) {
		super.showWidget(index);
		listeners.fireChange(this);
	}
	
	public void addMyChangeListener(MyChangeListener lis) {
		listeners.add(lis);
	}
	
	public void removeMyChangeListener(MyChangeListener lis) {
		listeners.remove(lis);
	}
	
}
